package com.extremeforce.parser;

import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

public abstract class IGuangXMLParser {
	
	public  ArrayList<HashMap<String,String>> parse(String content){
		SAXBuilder builder = new SAXBuilder(false);
		ArrayList<HashMap<String,String>> list = null;
		
		
		try{
			File tempFile = File.createTempFile("iguang" + System.nanoTime(),".txt");
			FileOutputStream fos = new FileOutputStream(tempFile);
			fos.write(content.getBytes());
			fos.close();
			
			Document doc = builder.build(tempFile);
			
			Element roots = doc.getRootElement();
			list = process(roots);
			tempFile.delete();
			
		}catch(Exception e){
			e.printStackTrace();
		}
		return list;
	}
	public abstract ArrayList<HashMap<String,String>> process(Element element);
}
